package student;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Test {

	public static void main(String[] args) {
		Map map = new HashMap();

		Scanner sc = new Scanner(System.in);

		int num = 0, age = 0;

		String name = null, idcard = null;

		Student stu;
		while (true) {
			System.out.println("1:显示全部学员\t2：删除\t3：添加\t9:退出\n请输入您的选择：");
			int ch = sc.nextInt();
			switch (ch) {
			case 1:
				System.out.println("显示信息如下：");
				Set keys = map.keySet();
				Iterator ir = keys.iterator();
				while (ir.hasNext()) {
					Object key = ir.next();
					Object value = map.get(key);
					if (value instanceof Student) {
						System.out.println(value);
					}
				}
				break;
			case 2:
				System.out.println("请输入要删除的身份证号：");
				idcard = sc.next();
				if (map.containsKey(idcard)) {
					map.remove(idcard);
					System.out.println("删除成功");
				} else {
					System.out.println("查无此人");
				}
				break;
			case 3:
				System.out.println("请输入学号：");
				num = sc.nextInt();
				System.out.println("请输入年龄：");
				age = sc.nextInt();
				System.out.println("请输入姓名：");
				name = sc.next();
				System.out.println("请输入身份证号：");
				idcard = sc.next();
				stu = new Student(num, age, name, idcard);
				if (!map.containsKey(idcard)) {
					map.put(idcard, stu);
					System.out.println("添加成功");
				} else {
					System.out.println("添加失败");
				}
				break;
			case 9:
				return;
			default:
				System.out.println("请重新选择");
			}// switch循环

		}// while循环

	}

	}


